package JAVA300.第十一章多线程;

/**
 * lamda表达式更改runnable实现方式
 */
public class thread_08_lamdaStart {
    //静态内部类
    static class Test implements Runnable{

        @Override
        public void run() {
            for (int i= 0;i<10;i++){
                System.out.println("this is thread"+i);
            }
        }

    }

    public static void main(String[] args) {

       //创建实现类对象
//        thread_04_startByImplement threadStart = new thread_04_startByImplement();
//        new Thread(threadStart).start();
//
   //    new Thread(new Test()).start();

        for (int i= 0;i<10;i++){
            System.out.println("this is main"+i);//无规律的交替进行
        }


        //局部内部类
         class Test1 implements Runnable{
            @Override
            public void run() {
                for (int i= 0;i<10;i++){
                    System.out.println("this is thread"+i);
                }
            }

        }
        new Thread(new Test1()).start();

        //匿名内部类--借助父类或者接口
        new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i= 0;i<10;i++){
                    System.out.println("this is thread"+i);
                }

            }
        }).start();

        //jdk8
        new Thread(()-> {
                for (int i= 0;i<10;i++){
                    System.out.println("this is thread"+i);
                }
        }).start();

    }
}
